﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.RB
{
    class Class4
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                if (ppa.Period == 0)
                {
                    da.Value = ppa.TotalFee;
                }
                else if (ppa.Age < 18)
                {
                    da.Value = ppa.TotalFee * 1.1;
                }
                else
                {
                    da.Value = ppa.Amount * 2;
                }
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Age==18 || ppa.Age==22 || ppa.Age==25)
            {
                da.Value = ppa.Amount * 0.8;
            }
            else if (ppa.Age ==30)
            {
                da.Value = ppa.Amount * 0.6;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.HolderStates.Contains("身故"))
            {
                if (ppa.Age < 18)
                {
                    da.Value = ppa.TotalFee * 1.2;
                }
                else
                {
                    double t = ppa.Amount * 3;
                    double x = ppa.GetDutyTotalValue("生存保险金与满期保险金 ");

                    da.Value = t - x;
                }

                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Age < 18)
            {
                IPolicyPeriodActing ppa2=ppa.PolicyActing.PeriodActings.FirstOrDefault(p => p.Age < 18  && p.Period<ppa.Period && (p.SchemePeriodActing.HolderStates.Contains("身故") || p.SchemePeriodActing.HolderStates.Contains("高度残疾")));

                if (ppa2 != null)
                {
                    da.Value = ppa.Amount * 0.5;
                    ppa.Fee = 0;
                }
            }
        }
    }
}
